import { paramTypeMap ,requestTypeMap } from "./const"

type ParamTypeMapKeys = keyof typeof paramTypeMap;
type RequestTypeVals = keyof typeof requestTypeMap;
export type ParamItem = {
  childList: UnionParamItem[];
  paramKey: string;
  paramName: string;
  paramNotNull: '0' | '1'; // 参数是否可缺省，1可缺省，0不可缺省
  paramType: ParamTypeMapKeys;
}

interface StructureParamItem extends Partial<ParamItem> {
  structureID?: number;
}

export type UnionParamItem = StructureParamItem & ParamItem;


export interface DataStructureList {
  [propName: string]: {
    structureData: UnionParamItem[];
    structureType: ParamTypeMapKeys
  };
}
interface BaseInfo {
  apiName: string;
  apiURI: string;
  apiRequestType: RequestTypeVals;
  apiRequestParamJsonType: 0 | 1; // body请求参数外层JSON类型，0 Object 1 Array;
}
interface ApiInfo {
  baseInfo: BaseInfo;
  dataStructureList: DataStructureList;
  requestInfo: UnionParamItem[];
  urlParam: UnionParamItem[];
  restfulParam: UnionParamItem[];
  resultInfo: { isDefault: 0 | 1, responseCode: number, responseName: string, paramList: UnionParamItem[], responseID: number }[];
  resultParamJsonType:  0 | 1; // 返回参数外层JSON类型，0 Object 1 Array;
}


export interface ApiDataType {
  apiInfo: ApiInfo;
  hasUnreadComment:number;
  statusCode: string;
  type: string;
  errorMsg?:string;
}
